﻿// ================================================================================
//        File: EmployeeBLL.cs
//        Desc: 员工增、查、改相应操作
//        Auth: JF
//        Date: 2010-09-19
// ================================================================================
//        Change History
// ================================================================================
//        Date:         Author:                  Description:
//        --------     --------              -------------------
//              
// ================================================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using EShop.Model;

using EShop.DAL;

namespace EShop.BLL
{

    public class EmployeeBLL
    {

        EmployeeDAL oEmployeeDAL=new EmployeeDAL();

        /// <summary>
        /// 增加一个新的员工，增加成功后返回新添加员工的信息
        /// 返回列表：EmployeeID,EmployeePWD,FullName,EmployeePID,Sex,Brithday,IsGregorianCalendar,Popedom,[Address],Mobile,Remark,CreateDatetime,EmployeePurview 
        /// JF
        /// </summary>
        /// <param name="employeeInfo"></param>
        /// <returns></returns>
        public DataTable AppendEmployeeInfo(EmployeeInfo oEmployeeInfo)
        {
            return oEmployeeDAL.AppendEmployeeInfo(oEmployeeInfo);
        }

        /// <summary>
        /// 修改员工信息
        /// </summary>
        /// <param name="oEmployeeInfo"></param>
        /// <returns></returns>
        public bool UpdateEmployeeInfo(EmployeeInfo oEmployeeInfo)
        {
            return oEmployeeDAL.UpdateEmployeeInfo(oEmployeeInfo);
        }

        /// <summary>
        /// 员工登录
        /// 登录成功后，获取该员工的信息
        /// 更新最后登录时间
        /// </summary>
        /// <param name="strEmployeeID">工号</param>
        /// <param name="strEmployeePWD">密码</param>
        /// <returns></returns>
        public EmployeeInfo EmployeeLogined(string strEmployeeID, string strEmployeePWD)
        {
            //TODO: MD5
            return oEmployeeDAL.EmployeeLogined(strEmployeeID, strEmployeePWD);
        }

        /// <summary>
        /// 取所有员工的权限数据
        /// </summary>
        /// <returns></returns>
        public List<EmployeeInfo> GetEmployeePermission()
        {
            return oEmployeeDAL.GetEmployeePermission();
        }

        /// <summary>
        /// 修改相应员工的权限
        /// </summary>
        /// <param name="strEID">EmployeeID </param>
        /// <param name="iPermission"> 权限值</param>
        /// <returns></returns>
        public bool UpdateEmployeePermission(string strEID, int iPermission)
        {
            return oEmployeeDAL.UpdateEmployeePermission(strEID, iPermission);
        }

        /// <summary>
        /// 查询所有[指定]员工信息。
        /// 
        /// </summary>
        /// <param name="strEmployeeID"></param>
        /// <param name="iBeginIndex"></param>
        /// <param name="iLenght"></param>
        /// <returns></returns>
        public DataTable QueryEmployeeInfo(string strEmployeeID)
        {
            return oEmployeeDAL.QueryEmployeeInfo(strEmployeeID);
        }

        public DataTable SearchEmployee(string strKeyword, int type)
        {
            return oEmployeeDAL.SearchEmployee(strKeyword, type);
        }

        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="strEmployeeID"></param>
        /// <param name="strPassword"></param>
        /// <returns></returns>
        public bool ChangePassword(string strEmployeeID, string strPassword)
        {
            return oEmployeeDAL.ChangePassword(strEmployeeID, strPassword);
        }
    }
}
